﻿<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="Debugger.AddIn.Pads.Controls.WatchList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Debugger.AddIn.Pads.Controls"
             xmlns:core="http://icsharpcode.net/sharpdevelop/core"
             xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview">
	<UserControl.Resources>
		<local:BoolToVisibilityConverter x:Key="boolToVisibility" />
		<Style x:Key="BorderStyle" TargetType="Border">
			<Setter Property="BorderBrush" Value="LightGray" />
			<Setter Property="BorderThickness" Value="1,0,1,1"></Setter>
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="HorizontalAlignment" Value="Stretch" />
		</Style>
		<Style TargetType="{x:Type TextBox}" x:Key="TextBoxValueStyle">
			<Setter Property="BorderThickness" Value="0"/>
			<Setter Property="BorderBrush" Value="Transparent"/>
			<Setter Property="Background" Value="White"/>
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Visibility">
				<Setter.Value>
					<MultiBinding Converter="{StaticResource boolToVisibility}" ConverterParameter="True">
						<Binding Path="Node.CanSetText" />
						<Binding Path="IsSelected" />
					</MultiBinding>
				</Setter.Value>
			</Setter>
		</Style>
		<Style TargetType="{x:Type TextBlock}" x:Key="TextBlockValueStyle">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Visibility">
				<Setter.Value>
					<MultiBinding Converter="{StaticResource boolToVisibility}" ConverterParameter="False">
						<Binding Path="Node.CanSetText" />
						<Binding Path="IsSelected" />
					</MultiBinding>
				</Setter.Value>
			</Setter>
		</Style>
		<!-- Value column -->
		<DataTemplate x:Key="CellTemplate_Value">
			<StackPanel Orientation="Horizontal">
				<TextBlock VerticalAlignment="Center" MinWidth="200" Text="{Binding Node.Text}" Style="{StaticResource TextBlockValueStyle}" />
				<TextBox Text="{Binding Node.Text, Mode=OneWay}" Style="{StaticResource TextBoxValueStyle}" KeyUp="OnValueTextBoxKeyUp" />
			</StackPanel>
		</DataTemplate>
		<!-- Type column -->
		<DataTemplate x:Key="CellTemplate_Type">
			<TextBlock VerticalAlignment="Center" MinWidth="200" Text="{Binding Node.Type}" />
		</DataTemplate>
	</UserControl.Resources>
	<DockPanel>
		<tv:SharpTreeView x:Name="myList" ShowRoot="False" PreviewMouseDoubleClick="MyListPreviewMouseDoubleClick" AllowDrop="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=AllowDrop}">
			<tv:SharpTreeView.View>
				<tv:SharpGridView>
					<GridView.Columns>
						<GridViewColumn Header="{core:Localize Global.Name}" Width="400">
							<GridViewColumn.CellTemplate>
								<DataTemplate>
									<tv:SharpTreeNodeView>
										<tv:SharpTreeNodeView.CellEditor>
											<local:WatchListAutoCompleteCell
												CommandText="{Binding Node.Name, Mode=OneWay}"
												CommandEntered="WatchListAutoCompleteCellCommandEntered"/>
										</tv:SharpTreeNodeView.CellEditor>
									</tv:SharpTreeNodeView>
								</DataTemplate>
							</GridViewColumn.CellTemplate>
						</GridViewColumn>
						<GridViewColumn Header="{core:Localize Dialog.HighlightingEditor.Properties.Value}"
						                CellTemplate="{StaticResource CellTemplate_Value}"
						                Width="200" />
						<GridViewColumn Header="{core:Localize ResourceEditor.ResourceEdit.TypeColumn}"
						                CellTemplate="{StaticResource CellTemplate_Type}"
						                Width="200" />
					</GridView.Columns>
				</tv:SharpGridView>
			</tv:SharpTreeView.View>
		</tv:SharpTreeView>
	</DockPanel>
</UserControl>